gtk-demo: Fix revealer demo
authorMatthias Clasen <mclasen@redhat.com>
Sat, 7 May 2016 20:22:13 +0000 (16:22 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 7 May 2016 20:22:13 +0000 (16:22 -0400)
This only used by luck before. We are changing a property from the
::notify handler for that property. Now that GtkRevealer is notifying
the property when it stops animations on unmap, we end up in a life
lock situation where we never make it out of the notify queue.

Fix this by not restarting the animation if the widget is unmapped.

demos/gtk-demo/revealer.c

index 23092d059a45a79d15785de37132790751f5d859..2cccb7a7ed44ad095f12caf53f48a4980948945c 100644 (file)
@@ -12,10 +12,13 @@ static guint timeout = 0;
 static void
 change_direction (GtkRevealer *revealer)
 {
-  gboolean revealed;
+  if (gtk_widget_get_mapped (GTK_WIDGET (revealer)))
+    {
+      gboolean revealed;
 
-  revealed = gtk_revealer_get_child_revealed (revealer);
-  gtk_revealer_set_reveal_child (revealer, !revealed);
+      revealed = gtk_revealer_get_child_revealed (revealer);
+      gtk_revealer_set_reveal_child (revealer, !revealed);
+    }
 }
 
 static gboolean